import java.awt.*;
import java.awt.event.MouseEvent;

public class Sky {
        //关卡数
        static int level=1;
        //目标金额
       static int goal=level*200+100;
        //总金额
        static  int total=0;
        static  int  yaoBasic=3;//初始药水值
        //药水状态
        static  boolean yaoState=false;
        static int price=10;
        //是否进入商店
        static boolean shop=false;
        //开始时间
        static long startTime;
        //结束时间
        static long endTime;
        //倒计时
        static long tim;
        static Image yao= Toolkit.getDefaultToolkit().getImage("img/yao.jpg");
        static Image bg= Toolkit.getDefaultToolkit().getImage("img/bg.jpg");//背景
        static Image sky= Toolkit.getDefaultToolkit().getImage("img/sky.jpg");//天空
        static Image worker1= Toolkit.getDefaultToolkit().getImage("img/worker1.jpg");//人
        public static void paint(Graphics g) {//绘制位图
            g.drawImage(sky,0,0,null);
            switch (GameWin.state){
                case 0:
                    g.drawImage(bg,0,200,null);
                    draw(g,50,"准备开始，双击右键",150,400,Color.green);
                    break;
                case 1:
                    goal=level*200+100;//设置关卡的目标分数
                    g.drawImage(bg,0,200,null);
                    g.drawImage(worker1,310,50,null);
                    draw(g,30,"目标得分"+goal,30,110,Color.black);
                    draw(g,30,"积分:"+total,30,150,Color.BLACK);
                    draw(g,30,"*"+yaoBasic,510,70,Color.black);
                    //关卡数
                    draw(g,20,"第"+level+"关",30,60,Color.black);
                    //计算时间
                     endTime=System.currentTimeMillis();
                     long tim=20-(endTime-startTime)/1000;
                    draw(g,30,"时间:"+(tim>0?tim:0),520,90,Color.BLACK);//repaint
                    break;
                case 2:
                    Shop.paint(g);
                    if (shop)
                    {
                        total-=price;
                        yaoBasic++;
                        shop=false;
                        startTime=System.currentTimeMillis();
                    }
                    break;
                case 3:
                    g.drawImage(bg,0,200,null);
                    draw(g,50,"你失败啦！",250,350,Color.RED);//repaint
                    draw(g,50,"总金额"+total,200,450,Color.BLACK);
                    break;
                case 4:
                    g.drawImage(bg,0,200,null);
                    draw(g,50,"您通关啦！",250,350,Color.RED);//repaint
                    draw(g,50,"总金额"+total,200,450,Color.BLACK);
                    break;
                default:
            }
            g.drawImage(yao,450,40,null);
            draw(g,30,"*"+yaoBasic ,510,70,Color.black);
        }
        public static  void  draw(Graphics g,int size,String str,int x,int y,Color color){
            g.setColor(color);
            g.setFont(new Font("楷体",Font.BOLD,size));
            g.drawString(str,x,y);
        }
        //倒计时
        boolean gameTime(){
            long tim=(endTime-startTime)/1000;
            if(tim>20){
                return true;
            }
            return false;
        }
        //重置元素
        void reGame(){
            //定义关卡数
            int level=1;
            //目标金额
            int goal=level*200+100;
            //总金额
            int total=0;
            int  yaoBasic=3;//初始药水值
            //药水状态
            boolean yaoState=false;
        }
    }

